#coding:utf-8
from sqlalchemy import Column, CHAR, INT, VARCHAR, DATE, DATETIME
from app import db

# 定义对象:
class StuInfo(db.Model):
	# 表的名字:
	__tablename__ = 'stuinfo'

	# 表的结构:
	StuID = Column(CHAR(12), primary_key=True)
	Password = Column(VARCHAR(45))
	Name = Column(VARCHAR(45))
	Gender = Column(CHAR(1))
	Class = Column(CHAR(10))
	Dormitory = Column(CHAR(8))
	Phone = Column(CHAR(11))
	Date = Column(DATE)

class Computer(db.Model):
	__tablename__ = 'computer'
	ComputerID = Column(INT,primary_key=True)
	RoomID = Column(CHAR(4), primary_key = True)
	Password = Column(VARCHAR(45))
	isReady = Column(CHAR(1))
	isBreakdown = Column(CHAR(1))

class Reservation(db.Model):
	__tablename__ = 'reservation'
	StuID = Column(CHAR(12),primary_key=True)
	ResDate = Column(DATE, primary_key = True)
	isDone = Column(CHAR(1),default='N')
	ComputerID = Column(INT)
	RoomID = Column(CHAR(4))
	StartTime = Column(DATETIME)
	FinishTime = Column(DATETIME)

# 定义Admin对象:
class Admin(db.Model):
	# 表的名字:
	__tablename__ = 'admin'

	# 表的结构:
	AdminID = Column(VARCHAR(45), primary_key=True)
	Name = Column(VARCHAR(45))
	Password = Column(VARCHAR(45))
	#登陆信息
	is_authenticated = True
	is_active = True
	is_anonymous = False
 
	def get_id(self):
		return unicode(self.AdminID)
 
	def __repr__(self):
		return '<User %r>' % (self.Name)

class Log(db.Model):
	__tablename__ = 'log'
	StuID = Column(CHAR(12),primary_key=True)
	Time = Column(DATETIME, primary_key = True)
	Action = Column(VARCHAR(45))

class Statistics():
	ID = ""
	Name = ""
	Class = ""
	Count = 0
	All = 0
	Percent = 0.0
	